home *** CD-ROM | disk | FTP | other *** search
- @2
- ARRAYS IN AMOS
- ==============
- @1
- You probably all know how to use arrays in AMOS. If not you`re missing
- out on a treat that is needed to fully appreciate the programming
- language.
-
- An array is a storage area in the computer`s memory. Just like a
- variable it is given a name, but it is also given a size. Because of
- this it is important to set it up before it can be used.
-
- To do this use the command:
- @2
- Dim ARRAY(N) -where ARRAY is the name of the array
- N is the size of the array.
- @1
- The array name follows the standard format of variables in AMOS, eg
- NUMBERS for numeric data or LETTER$ for words. The command creates a
- series of boxes numbered from 0 to N that can each be written to in
- the same way as any other variable (provided the number part or element
- of the array is specified).
-
- Each element will initially be blank, that`s the equivalent of 0 in a
- numerical array or "" in any other.
-
- For example try this program to create an array in AMOS and fill it
- from random numbers.
-
- @2
- Dim NUMBERS(10)
- For COUNTER=0 To 10
- NUMBERS(COUNTER)=Rnd(9)+1
- Next COUNTER
- @1
-
- This is the equivalent of creating 11 variables and filling them with a
- number from 1 to 10. As I`m sure you`ll appreciate this is a much more
- efficient method and has the advantage that it is much easier to call
- up a particular value. Arrays have major uses in any of today`s games
- or application programs.
- @3
- Thomas Lancaster
-